<template>
    <div class="mt-96">
        <!--付款金额-->
        <div class="pay-money">
            <span class="color-000">付款金额</span><span class="common-color ml-20 ">￥<i
                class="fontarial">{{totalMoney}}</i><label
                v-text="tipText"></label></span>
        </div>
        <!--付款方式-->
        <div class="WeChat-pay mt-20">
            <a @click="pay(1)">
                <img src="~images/pay-weix.png" alt="微信支付"><span class="f36 ml-20 color-000">微信支付</span>
                <i class="to-right"></i>
            </a>
        </div>
        <div class="Alipay-pay">
            <a @click="pay(2)">
                <img src="~images/pay-zfb.png" alt="支付宝支付"><span class="f36 ml-20 color-000">支付宝支付</span>
                <i class="to-right"></i>
            </a>
        </div>
    </div>
</template>

<script>
    export default {
        name: '',
        data () {
            return {
                type: '',
                /*1代练订单,2陪练单子*/
                tipText: '',
                totalMoney: "",
                orderPayType: '',
                paySort: '',
                postData: {
                    levelingOrderId: this.$route.query.orderNum,
                    isOffice: 1,
                }
            }
        },
        created(){

        },
        mounted(){
            var self = this;
            if (self.$route.query.type == 1) {
                self.$bus.emit('headerText', `支付押金`);
                self.tipText = '代练完成后全额退还';
                self.orderPayType = 'bullyOrder/';
                self.paySort = 'payment/payforleveldeposit';
            } else if (self.$route.query.type == 2) {
                self.$bus.emit('headerText', `支付押金`);
                self.tipText = '订单支付金额';
                self.orderPayType = 'playerOrder/';
                self.paySort = 'payment/payforsparringdeposit';
            }
            self.getOrderInfo();
        },
        destroyed(){
            var self = this;
            self.$bus.emit('headerText', '');
        },
        methods: {
            getOrderInfo(){
                var self = this;
                self.$http.get(self.$CONSTANTS.APIdl + self.orderPayType + self.$route.query.orderNum).then((res) => {
                    if (res.body.responseStatus.code == '00' && res.body.levelingOrder != null) {
                        self.totalMoney = res.body.levelingOrder.bullyDeposit || res.body.levelingOrder.totalAmount;
                    } else {
                        this.$messagebox.alert(res.body.responseStatus.message).then(action => {
                            this.$router.go(-1);
                        })
                    }
                }, (res) => {
                    console.log(res)
                });
            },
            pay(s){
                var self = this;
                self.postData.payType = s;
                self.$http.post(self.$CONSTANTS.APIdl + self.paySort, self.postData).then((res) => {
                    if (s == 2) {
                        var message = res.body.result;
                        document.write(message);
                    } else if (s == 1) {
                        window.location.href = res.body.result;
                    } else {
                        this.$messagebox.alert(res.body.responseStatus.message);
                    }
                }, (res) => {
                    console.log(res)
                });
            }
        }
    }
</script>

<style src="css/dlAll/dl-cxy.css"></style>
<style scoped>

</style>
